// Oliver Shyal Beardsley
// 17/2/2011

//! Deck class declaration

#ifndef _DECK_H_
#define _DECK_H_

#include <vector>
#include "Card.h"

#include <fstream>
#include <QMutex>
#include <QMap>
#include <QUuid>

class Deck
{
	public:

		//! class constructor
		Deck();
		//! class destructor
		~Deck();
		Deck(const Deck&);
		friend QDataStream			&operator<<( QDataStream &stream, const Deck &data);
		//friend QDataStream		&operator>>( QDataStream &stream, Deck &data);

		void						readFromVer0(QDataStream &stream, int cardsCount);
		void						readFromVer1(QDataStream &stream);
		void						readFromVer2(QDataStream &stream);

		size_t						size() const;

		void						addCard(Card*);
		void						deleteCard(Card*);
		void						knewCurrentCard();

		Card	*					getCard(const QUuid&) const;

		void						updateCard(Card* card);

		void						setPath(QString);
		QString						getPath();

		int							getLastDisplayed() const;
		int							getFirstDisplayed() const;
		int							getAge() const;

		bool						hasChanged() const;
		void						setSaved();

		bool						hasCard(const QUuid&) const;

		void						clear();

	private:


	private:
		QMap<QUuid, Card*>			m_cardsMap;
		QString						m_path;
		bool						m_changed;
		QMutex*						m_pUpdateMutex;
};


#endif
